#include "../begonia.h"
#include "boss_3_2_seino.h"
#include "../bullet/needlebullet.h"
#include "../base/scene.h"

boss_3_2_seino::boss_3_2_seino():boss(192.0,200.0,20.0,0.0,0.0,&f.head)
    {
        tstolen=0.0;
        fast=false;
    }
boss_3_2_seino::boss_3_2_seino(double tx,double ty,double tr,double tvx,double tvy,bullet *h):boss(tx,ty,tr,tvx,tvy,h)
    {
    }
void boss_3_2_seino::clone(bullet *h)
    {
        new boss_3_2_seino(x,y,r,vx,vy,h);
    }
bool boss_3_2_seino::move()
    {
        if(fast)
        {
            tfact=1.5;
            tstolen-=0.5;
            if(tstolen<0.5) fast=false;
            if((int)t/12>(int)tlast/12)
            {
                double t0=atan2(f.py-y,f.px-x);
                for(int i=0;i<6;i++)
                {
                    new needlebullet(x,y,10.0,cos(M_PI*(2*i+1)/6+t0)*2.0,sin(M_PI*(2*i+1)/6+t0)*2.0,5.0,&f.head);
                }
            }
        }
        else
        {
            double dist2,tardist;
            dist2=sqr(x-f.px)+sqr(y-f.py);
            tardist=dist2>4900.0?70.0:sqrt(dist2);
            double t0=atan2(y-f.py,x-f.px)+0.01,tarx=f.px+cos(t0)*tardist,tary=f.py+sin(t0)*tardist;
            if(sqr(x-tarx)+sqr(y-tary)<1.0) {x=tarx;y=tary;}
            else
            {
                double theta=atan2(tary-y,tarx-x);
                x+=cos(theta);y+=sin(theta);
            }
            if(dist2<10000.0)
            {
                tfact=dist2/10000.0;
                tstolen+=1.0-tfact;
                if(tstolen>=30.0) fast=true;
            }
            else tfact=1.0;
        }
        return true;
    }
